package com.ternnetwork.batch.service.impl.commons;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.ternnetwork.batch.dao.commons.BatchStepDataCountDao;
import com.ternnetwork.batch.enums.BatchStepDataCountStatus;
import com.ternnetwork.batch.enums.BatchStepDataType;
import com.ternnetwork.batch.model.commons.BatchStepDataCount;
import com.ternnetwork.batch.service.commons.BatchStepDataCountService;


@Service("batchStepDataCountService")
public class BatchStepDataCountServiceImpl implements BatchStepDataCountService {

	@Resource
	private BatchStepDataCountDao batchStepDataCountDao;
	
	
	public void idoAdd(Integer writeCount, Integer commitCount, Integer filterCount, Integer readCount,
			Integer rollbackCount, Integer skipCount, Integer processSkipCount, Integer readSkipCount,
			Integer writeSkipCount, String batchNo, BatchStepDataType dataType, BatchStepDataCountStatus status){
		BatchStepDataCount  t=new BatchStepDataCount(writeCount, commitCount, filterCount, readCount, rollbackCount, skipCount, processSkipCount, readSkipCount, writeSkipCount, batchNo, dataType, status);
		batchStepDataCountDao.persist(t);
	}
	
	public BatchStepDataCount find(String batchNo,BatchStepDataType dataType){
		List<BatchStepDataCount>  list=batchStepDataCountDao.findAll("from BatchStepDataCount t where t.batchNo=?1 and t.dataType=?2 ", batchNo,dataType);
	    return list.size()>0?list.get(0):null;
	}
	
	
}
